// 远程获取新闻和新闻列表的数据
import axios from "axios"
import {APPCODE} from "./config"
/**
 * 获取所有的新闻类别
 */
export async function getNewsChannels(){
  var resp = await  axios.get('http://ali-news.showapi.com/channelList',{
        headers:{
            Authorization:`APPCODE ${APPCODE}`
        }
    })
   return resp.data.showapi_res_body.channelList
}

/**
 * 
 * @param {*} channelId 
 * @param {*} page 
 * @param {*} limit 每页展示多少数据
 */
export async function getNews(channelId,page = 1,limit = 10){
    var resp = await  axios.get('http://ali-news.showapi.com/newsList',{
        headers:{
            Authorization:`APPCODE ${APPCODE}`
        },
        params:{
            channelId,
            page,
            maxResult:limit,
            needAllList:false,
            needContent: 1
        }
    })
   return resp.data.showapi_res_body.pagebean;
}
